<template>
  <div v-show="visible && menuItems && menuItems.length" class="v-property-bar" :style="styleC">
    <div class="g-bg-white _bar-content">
      <div v-for="(item,index) in menuItems" :key="index" class="g-pd-2 g-pointer">
        <div v-if="index>0 && item.type !== menuItems[index-1].type"  style="width:24px; margin:4px 0 6px 0; border-bottom:1px solid #c0c0c0"></div>
        <div class="_img-wrap"  @click="$emit('click-btn',item)">
          <img
            class="_img"
            :src="item.iconPath"
            :title="item.label"
          />
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { Portal } from "src/components/common/Portal";

const comp = {
  name: "popmenu",
  components: {},
  props: {
    x: Number,
    y: Number,
    visible: Boolean,
    menuItems: Array

  },
  data() {
    return {

    };
  },
  computed: {
    styleC() {
      return {
        left: this.x + "px",
        top: this.y + "px"
      };
    },

  },
  methods: {
    handleOk(res) {
      this.visible = false;
      this.$emit("sure", res);
    },
    handleCancel() {
      this.visible = false;
      this.$emit("close");
    }
  }
};
export default comp;
export const propertyBar = new Portal(comp);
</script>
<style lang="scss">
.v-property-bar {
	position: absolute;
  //// padding-left: 22px;
  margin-left:22px;
  ._bar-content {
    box-shadow:0px 9px 28px 8px rgba(0,0,0,0.05),0px 6px 16px 0px rgba(0,0,0,0.08),0px 3px 6px -4px rgba(0,0,0,0.12);
    border-radius: 0px;
    border: 1px #B1CEE2 solid;
    display: flex;
    flex-direction: column;
    padding: 2px 4px;
    ._img-wrap {
      text-align: center;
      line-height: 16px;
      padding: 4px;
      &:hover {
				background: linear-gradient(107deg, #a3dbff 0%, #74c5f8 100%)
			}
      &:active {
				background: linear-gradient(107deg, #7FC8F6 0%, #3EA5E6 100%)
			}
    }
    ._img {
      width:16px;
    }
  }
}
</style>
